package hn.sigit.model.hnd.cadastre;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import hn.sigit.model.commons.IEasement;
import hn.sigit.model.commons.IRegistration;
import hn.sigit.model.hnd.administrative.HND_Registration;

@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="HND_Easement", schema="hnd_cadastre")
@Inheritance(strategy=InheritanceType.JOINED)
public class HND_Easement implements IEasement {
	private Long id;
	private HND_EasementType type;
	private HND_DocumentType documentType;
	private Integer beneficiaryNumber;
	private HND_Registration registration;
	
	
	@Id
	@Column(name="ID", nullable=false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="hnd_easement_id_gen")
	@SequenceGenerator(name="hnd_easement_id_gen", sequenceName="hnd_easement_id_seq", allocationSize=1)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="Type", nullable=false)
	@Enumerated(EnumType.STRING)
	public HND_EasementType getType() {
		return type;
	}
	public void setType(HND_EasementType type) {
		this.type = type;
	}
	
	@Column(name="DocumentType", nullable=false)
	@Enumerated(EnumType.STRING)
	public HND_DocumentType getDocumentType() {
		return documentType;
	}
	public void setDocumentType(HND_DocumentType documentType) {
		this.documentType = documentType;
	}
	
	@Column(name="BeneficiaryNumber", nullable=true)
	public Integer getBeneficiaryNumber() {
		return beneficiaryNumber;
	}
	public void setBeneficiaryNumber(Integer beneficiaryNumber) {
		this.beneficiaryNumber = beneficiaryNumber;
	}
	
	@Embedded
	public HND_Registration getRegistration() {
		if (registration == null)
			registration = new HND_Registration();
		return registration;
	}
	public void setRegistration(IRegistration registration) {
		if (registration != null && !(registration instanceof HND_Registration))
			throw new IllegalArgumentException("HND_Registration type required");
		this.registration = (HND_Registration) registration;
	}
}
